import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *


class QMainWindow_new(QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.isDragging = False
        self.dragPos = None
        self.setWindowFlag(Qt.FramelessWindowHint)
        self.setWindowIcon(QIcon("./ui/label.jpg"))

    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.isDragging = True
            self.dragPos = event.globalPos() - self.frameGeometry().topLeft()
            event.accept()
            self.setCursor(QCursor(Qt.OpenHandCursor))

    def mouseMoveEvent(self, event):
        if self.isDragging:
            self.move(event.globalPos() - self.dragPos)
            event.accept()

    def mouseReleaseEvent(self, event):
        if self.isDragging and event.button() == Qt.LeftButton:
            self.isDragging = False
            self.setCursor(QCursor(Qt.ArrowCursor))
            event.accept()